home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
3_0
/
MIDIMERG
/
README
< prev
Wrap
Text File
|
1988-12-09
|
4KB
|
109 lines
MIDIMERGER 1.0
~~~~~~~~~~~~~~
MidiMerger is a LSC package which I designed for use in synthesiser
voice editing packages. It allows data from a keyboard or
external device to be echoed to the output MIDI device, merged
with any data generated by the Mac. For example, the input
device might be a master keyboard, the output device an expander.
The routines will drive either or both serial
ports in whatever combination you want, so you can (for
example) echo MODEM in to PRINTER out, and vice versa, merging
Mac. generated data with either.
MidiMerger DOESN'T
- let you see the data coming from the external device;
I'm assuming you don't care about this;
- associate timing information with input data.
Both of these functions can be obtained from the assember MIDI.Lib
module which MidiMerger uses.
I don't know of any bugs. I've tested the merging code in
MODEM=>MODEM and PRINTER=>PRINTER configurations, but not cross-wise.
If you have two MIDI interfaces (lucky devil!), please try it.
Currently, MidiMerger throws away active sensing bytes. This is because
MidiMerger relies on your application calling idleMidi() as often as
possible to echo everything. If you pull down a menu, you don't get to
call idleMidi(), and if your keyboard was sending out active sensing,
the destination device cuts off. I do echo through all the other system
realtime messages though, such as the MIDI clock. Of course, everything
will stop if you're using MIDI clock and pull down a menu...
MidiMerger understands (as far as I can ascertain) MIDI Timecode (MTC);
well, at least, it knows that F1 1/4-frame messages have two following
bytes. I can't think of any other part of
the MIDI spec which is under development and liable to break things - as
far as I know, the other extensions have taken place within the System
Exclusive framework.
MidiMerger FreeWare by Nick Rothwell, 1988. The underlying MIDI
assembler routines aren't mine, though, they're Kirk Austin's.
Do what you like with MidiMerger, give it to your friends, etc. I'd quite
like a mention in your about-box if you do use this stuff, and if you make
alterations, please make them clear, so we don't have several zillion
differently functional versions floating around. Otherwise, you can
contact me as follows:
Nick Rothwell
3/13 Forrest Hill
Edinburgh EH1 2QL
Scotland, UK.
nick@lfcs.ed.ac.uk
nick%lfcs.ed.ac.uk@uk.ac.ucl.cs.nss
Sorry? Oh yes, the routines. Ok, here we go:
typedef enum {
MODEM, PRINTER
} PORT;
Enumerated type for the ports. MidiMerger will run either or both ports;
but, don't start doing operations on a port you haven't initialised.
extern void startMidi(PORT port);
extern void stopMidi(PORT port);
Initialise and terminate a port for MIDI operations. Be sure to wind down
a port you've initialised, even within crash routines, as you don't want
the interrupt handles hanging around if you exit.
extern void channelise(PORT port, int channel);
extern void noChannelise(PORT port);
MIDI data from either or both ports can be channelised, so that it
appears to be transmitted on that channel. This should probably be
done on output rather than input. The difference is important - if you
have a keyboard on both ports, and an expander on both ports, then
you can channelise either or both keyboards, but not selectively on
the expanders. channel ranges from 1 to 16.
extern void transmitMidi(PORT port, BYTE *message);
Transmit a MIDI message to a port. transmitMidi knows about the format
of messages, so the length doesn't need to be specified. message should
point to the status byte of a MIDI message. System Exclusives, being of
indeterminate length, must be terminated by EOX (0xF7).
extern void idleMidi(PORT input, PORT output);
This is the *crucial* routine - it is responsible for echoing data from
input port to output. Think of it like SystemTask() - call it as often
as possible if you want your keyboard echoed reliably.
idleMidi can echo from either port to either port. You might wish to
put in a call like
idleMidi(MODEM, MODEM);
idleMidi(PRINTER, PRINTER);
if you have both ports active.
idleMidi and transmitMidi are atomic wrt. the MIDI messages.
transmitMidi sends an entire message. idleMidi, if it sees a message, will
take control until the entire message has been echoed. This is probably
not optimal, but is simplest way to do it.
Nick.